﻿using System;
using System.Collections.Generic;
using System.Text;

using YouHP.DALFactory;
using YouHP.Model;
using YouHP.IDAL;

namespace YouHP.BLL
{
    public class AdminBLL
    {
        /// <summary>
        /// 建立数据库访问层管理员操作对象
        /// </summary>
        public static readonly IAdmin adminDLL = DataAccess.CreateAdminDAL();

        #region 单件模式
        private static AdminBLL _Instance;
        public static AdminBLL Instance
        {
            get
            {
                if (_Instance == null) _Instance = new AdminBLL();
                return _Instance;
            }
        }
        #endregion

        /// <summary>
        /// 增加新管理员账户
        /// </summary>
        /// <param name="info">管理员信息对象</param>
        /// <returns>如果操作成功则返回True,否则返回False</returns>
        public bool CreateNewAdmin(AdminInfo adminInfo)
        {
            return adminDLL.CreateNewAdmin(adminInfo);
        }

        /// <summary>
        /// 删除管理员账户
        /// </summary>
        /// <param name="info">管理员信息对象</param>
        /// <returns>如果操作成功则返回True,否则返回False</returns>
        public bool DeleteAdminAccount(AdminInfo adminInfo)
        {
            return adminDLL.DeleteAdminAccount(adminInfo);
        }

        /// <summary>
        /// 读取管理员信息
        /// </summary>
        /// <param name="info">管理员信息对象</param>
        /// <returns>管理员信息对象</returns>
        public AdminInfo GetAdminByNameAndPassword(AdminInfo adminInfo)
        {
            return adminDLL.GetAdminByNameAndPassword(adminInfo);
        }

        /// <summary>
        /// 更新管理员账户
        /// </summary>
        /// <param name="info">管理员信息对象</param>
        /// <returns>如果操作成功则返回True,否则返回False</returns>
        public bool UpdateAdminPassword(AdminInfo adminInfo)
        {
            return adminDLL.UpdateAdminPassword(adminInfo);
        }
    }
}
